<%= stylesheets %>

<div id="shopping-cart">
  <h1>Shopping Cart</h1>
  
  <% form_tag do-%>
    <table class="cart-summary" width="100% ">
      <tr>
        <th colspan="2">Item</th>
        <th>Price</th>
        <th>Qty</th>
        <!--
        <th>Delete</th>
        -->
        <th>Total</th>
      </tr>
      <% for @item in @cart.cart_items %>
        <tr class="<%= cycle('even', 'odd') %>">
          <td width="100">
            <%=image_tag ('products/' + @item.product.filename, :size => '85x57')%>
          </td>
          <td valign="top">              
            <%=link_to @item.product.name, :controller => 'store', :action => 'show', :id => @item.product-%>
            <%= @item.variation.name if @item.variation %><br/>
            <%=truncate(@item.product.description, length = 100, truncate_string = "...")-%>
          </td>
          <td valign="top" width="75">$ <%= sprintf("%0.2f", @item.price) %></td>
          <td valign="top" width="50"><%= text_field "item[]", :quantity, :size => 1 -%></td>
          <td valign="top" width="75">$ <%= sprintf("%0.2f", @item.price * @item.quantity)-%></td>
        </tr>
      <% end %>      
    </table>
    <div id="subtotal">
      <h3>Subtotal $ <%= sprintf("%0.2f", @cart.total) %></h3>
      <%= submit_tag 'Update' %>
      <%= link_to "Checkout", :controller => 'checkout' %> <!-- todo: replace with image and surround with link -->
    </div>
  <% end %>
  <%if previous_location %>
    <p><a href="<%=previous_location%>">Continue Shopping</a></p>
  <%end%>  
  <% unless @cart.cart_items.empty? %>
    <p id="clear_cart_link">
      <small>
        <%= link_to "Empty Cart", :action => 'empty' %>
      </small>
    </p>
  <% end %>
</div>